const express = require('express');
const router = express.Router();
const { 
  getStudents, 
  getStudentById, 
  createStudent, 
  updateStudent, 
  deleteStudent 
} = require('../controllers/studentController');
const { protect } = require('../middleware/auth');

// 所有路由都需要认证
router.use(protect);

// 获取所有学生
router.get('/', getStudents);

// 获取单个学生
router.get('/:id', getStudentById);

// 创建学生
router.post('/', createStudent);

// 更新学生
router.put('/:id', updateStudent);

// 删除学生
router.delete('/:id', deleteStudent);

module.exports = router;
